import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/index',
      alias: '/',
      name: 'index',
      component: resolve => require(['@/views/index/index.vue'], resolve),
      children: [
        {
          path: '/',
          redirect: '/home'
        },
        {
          path: '/home',
          name: 'home',
          component: resolve => require(['@/views/home/home.vue'], resolve)
        },
        {
          path: '/personalCenter', // 个人中心
          name: 'personalCenter',
          component: resolve =>
            require(['@/views/personalCenter/index.vue'], resolve),
          children: [
            {
              path: '/',
              redirect: '/personalInformation'
            },
            {
              path: '/personalInformation',
              name: 'personalInformation',
              component: resolve =>
                require([
                  '@/views/personalCenter/personalInformation.vue'
                ], resolve)
            },
            {
              path: '/messageCenter',
              name: 'messageCenter',
              component: resolve =>
                require(['@/views/personalCenter/messageCenter.vue'], resolve)
            },
            {
              path: '/myCourse',
              name: 'myCourse',
              component: resolve =>
                require(['@/views/personalCenter/myCourse.vue'], resolve)
            },
            {
              path: '/myProject',
              name: 'myProject',
              component: resolve =>
                require(['@/views/personalCenter/myProject.vue'], resolve)
            },
            {
              path: '/myGame',
              name: 'myGame',
              component: resolve =>
                require(['@/views/personalCenter/myGame.vue'], resolve)
            },
            {
              path: '/myActivities',
              name: 'myActivities',
              component: resolve =>
                require(['@/views/personalCenter/myActivities.vue'], resolve)
            },
            {
              path: '/myCollection',
              name: 'myCollection',
              component: resolve =>
                require(['@/views/personalCenter/myCollection.vue'], resolve)
            },
            {
              path: '/personalGrowth',
              name: 'personalGrowth',
              component: resolve =>
                require(['@/views/personalCenter/personalGrowth.vue'], resolve)
            }
          ]
        },
        {
          path: '/makerMarket', // 创客集市
          name: 'makerMarket',
          component: () => import('@/views/makerMarket/index.vue'),
          children: [{
            path: '/project', // 创客项目
            name: 'project',
            component: resolve => require(['@/views/makerMarket/project/project.vue'], resolve)
          }, {
            path: '/projectDetails', // 创客详情页
            name: 'projectDetails',
            component: resolve => require(['@/views/makerMarket/projectDetails/projectDetails.vue'], resolve)
          }, {
            path: '/teacher', // 优秀导师
            name: 'teacher',
            component: resolve => require(['@/views/makerMarket/teacher/teacher.vue'], resolve)
          }, {
            path: '/teacherDetails',
            name: 'teacherDetails',
            component: resolve => require(['@/views/makerMarket/teacherDetails/teacherDetails.vue'], resolve)
          }, {
            path: '/customer', // 优秀创客
            name: 'customer',
            component: resolve => require(['@/views/makerMarket/customer/customer.vue'], resolve)
          },
          {
            path: '/customerDetails', // 优秀创客详情页
            name: 'customerDetails',
            component: resolve =>
              require(['@/views/makerMarket/customerDetails/customerDetails.vue'], resolve)
          }, {
            path: '/investor', // 投资人
            name: 'investor',
            component: resolve => require(['@/views/makerMarket/investor/investor.vue'], resolve)
          },
          {
            path: '/investorDetails', // 投资人详情页
            name: 'investorDetails',
            component: resolve =>
              require(['@/views/makerMarket/investorDetails/investorDetails.vue'], resolve)
          }, {
            path: '/investment_institutions', // 投资机构
            name: 'investment_institutions',
            component: resolve =>
              require(['@/views/makerMarket/investment_institutions/investment_institutions.vue'], resolve)
          },
          {
            path: '/investment_institutions_details', // 投资机构详情页
            name: 'investment_institutions_details',
            component: resolve =>
              require(['@/views/makerMarket/investment_institutions_details/investment_institutions_details.vue'], resolve)
          }, {
            path: '/service', // 服务机构
            name: 'service',
            component: resolve => require(['@/views/makerMarket/service/service.vue'], resolve)
          },
          {
            path: '/serviceDetails', // 服务机构详情页
            name: 'serviceDetails',
            component: resolve => require(['@/views/makerMarket/serviceDetails/serviceDetails.vue'], resolve)
          }]
        },
        {
          path: '/makerSalon', // 创业沙龙
          name: 'makerSalon',
          component: () => import('@/views/makerSalon/index.vue'),
          children: [{
            path: '/match', // 校园大赛
            name: 'match',
            component: resolve => require(['@/views/makerSalon/match/match.vue'], resolve)
          },
          {
            path: '/matchDetails', // 校园大赛详情页
            name: 'matchDetails',
            component: resolve => require(['@/views/makerSalon/matchDetails/matchDetails.vue'], resolve)
          }, {
            path: '/activity', // 双创活动
            name: 'activity',
            component: resolve => require(['@/views/makerSalon/activity/activity.vue'], resolve)
          },
          {
            path: '/activityDetails', // 双创活动详情页
            name: 'activityDetails',
            component: resolve =>
              require(['@/views/makerSalon/activityDetails/activityDetails.vue'], resolve)
          }, {
            path: '/information', // 创客资讯
            name: 'information',
            component: resolve => require(['@/views/makerSalon/information/information.vue'], resolve)
          },
          {
            path: '/informationDetails', // 创客资讯详情页
            name: 'informationDetails',
            component: resolve =>
              require(['@/views/makerSalon/informationDetails/informationDetails.vue'], resolve)
          }]
        },
        {
          path: '/featureClass', // 特色班
          name: 'featureClass',
          component: () => import('@/views/featureClass/index.vue'),
          children: [{
            path: '/knowledge',
            name: 'knowledge',
            component: resolve => require(['@/views/featureClass/knowledge/knowledge.vue'], resolve)
          },
          {
            path: '/knowledgeDetails',
            name: 'knowledgeDetails',
            component: resolve =>
              require(['@/views/featureClass/knowledgeDetails/knowledgeDetails.vue'], resolve)
          }, {
            path: '/curriculum',
            name: 'curriculum',
            component: resolve => require(['@/views/featureClass/curriculum/curriculum.vue'], resolve)
          },
          {
            path: '/curriculumDetails',
            name: 'curriculumDetails',
            component: resolve =>
              require(['@/views/featureClass/curriculumDetails/curriculumDetails.vue'], resolve)
          }, {
            path: '/classmatch',
            name: 'classmatch',
            component: resolve => require(['@/views/featureClass/classmatch/classmatch.vue'], resolve)
          },
          {
            path: '/classmatchDetails',
            name: 'classmatchDetails',
            component: resolve =>
              require(['@/views/featureClass/classmatchDetails/classmatchDetails.vue'], resolve)
          }]
        },
        {
          path: '/new', // 政策解读
          name: 'new',
          component: resolve => require(['@/views/new/new.vue'], resolve)
        },
        {
          path: '/newDetails', // 政策解读详情页
          name: 'newDetails',
          component: resolve => require(['@/views/newDetails/newDetails.vue'], resolve)
        },
        {
          path: '/fruitText', // 成果展示详情页
          name: 'fruitText',
          component: resolve => require(['@/views/fruitText/fruitText.vue'], resolve)
        },
        {
          path: '/download', // 下载中心
          name: 'download',
          component: resolve => require(['@/views/download/download.vue'], resolve)
        },
        {
          path: '/projectFruit', // 成果展示
          name: 'projectFruit',
          component: resolve => require(['@/views/projectFruit/projectFruit.vue'], resolve)
        },
        {
          path: '/business', // 服务机构详情页
          name: 'business',
          component: resolve => require(['@/views/business/business.vue'], resolve)
        }
      ]
    }
  ]
})

router.beforeEach(async (to, from, next) => {
  console.log(to)
  next()
})

router.afterEach(to => { })

export default router
